<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<jsp:include page="frame/header.jsp"></jsp:include>

<title>客户订单管理</title>

<style>
.pagination .active a {
	/*background-color: #CC0041;
	color:white;*/
}
div.in-line{
	margin-top:5px;
}
div.in-line label{
	width:70px;
	text-align:right;
}
#searchBtn{
	text-align:right;
}
.form-horizontal .form-actions {
padding-left: 0px;
}
</style>

</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">商家管理</a> <span class="divider">/</span></li>
					<li><a href="#">订单管理</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 订单信息列表
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<div id="search-form">
						<form id="searchForm" method="post" class="form-search span12" action="<c:url value="/seller/search_order"/>">
							<input type="hidden" name="pageNum" id="pageNum" value="${searchForm.pageNum }">
							<input type="hidden" name="orderId" id="orderId" value="0">
							<div class="in-line">
								<label>所属商家：</label> 
								<select id="sellerId" class="input-xlarge" name="sellerId"
									check-type="required" required-message="请选择所属商家">
									<option value="0">全部</option>
									<c:forEach var="seller" items="${sellers }">
										<option value="${seller.sellerId }"
											<c:if test="${searchForm.sellerId == seller.sellerId}">selected</c:if>>
											${seller.sellerName}</option>
									</c:forEach>
								</select> <label>关键词：</label> <input
									type="text" name="search" id="search" placeholder="关键词：客户姓名、订单号" 
									value="${searchForm.search }" class="input-xlarge search-query">
							</div>
							<div class="in-line">
								<label>订餐时间：</label> <input class="input-medium datepicker"
									name="orderDateStart" id="date1" type="text" value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input class="input-medium datepicker" name="orderDateEnd" id="date2"
									type="text" value="">
								<label>订单状态：</label> 
								<select id="status" class="input-medium" name="status">
									<option value="-1" <c:if test="${searchForm.status == -1 }">selected</c:if>>全部</option>
									<option value="0" <c:if test="${searchForm.status == 0 }">selected</c:if>>未处理</option>
									<option value="1" <c:if test="${searchForm.status == 1 }">selected</c:if>>已配送</option>
									<option value="2" <c:if test="${searchForm.status == 2 }">selected</c:if>>已完成</option>
									<option value="3" <c:if test="${searchForm.status == 3 }">selected</c:if>>已失效</option>
								</select>
								
								<button type="button" id="searchBtn"
									class="btn btn-success ">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
								<button type="button" id="clearBtn"
									class="btn ">&nbsp;&nbsp;重置&nbsp;&nbsp;</button>
							</div>
							
						</form>

					</div>
					<table id="userInfo" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th width="30">序号</th>
								<th >订单号</th>
								<th >客户姓名</th>
								<th >订货店铺</th>
								<th >订餐日期</th>
								<th >订餐时间</th>
								<th >总价格</th>
								<th >订单状态</th>
								<th width="50">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="order" items="${pageModel.result }" varStatus="status">
								<tr>
									<td>${status.index+1 }</td>
									<td>${order.orderNum }</td>
									<td>${order.name } </td>
									<td>${order.sellerName } </td>
									<td>${order.orderDate }</td>
									<td>${order.orderTime }</td>
									<td>${order.totalPrice }</td>
									<td>
										<c:choose>
											<c:when test='${order.status == 0 }'>
												未处理
											</c:when>
											<c:when test='${order.status == 1 }'>
												已发货
											</c:when>
											<c:when test='${order.status == 2 }'>
												已完成
											</c:when>
											<c:when test='${order.status == 3 }'>
												已失效
											</c:when>
										</c:choose>
									</td>
									<td><a href="javascript:edit('${order.orderId }')"><i
											class="icon-edit"></i></a> &nbsp;&nbsp; </td>
								</tr>
							</c:forEach>
							
							
						</tbody>
					</table>
					
					<div id="mypager" class="mypager"></div>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	
	var pageNum = "${pageModel.pageNum}";
	var totalPage = "${pageModel.totalPage}";
	var numPerPage = "${pageModel.numPerPage}";
	
	$(document).ready(function(){
		
		$('.datepicker').datepicker('option', 'dateFormat', 'yy-mm-dd'); 
		
		$( "#date1" ).datepicker( "setDate", "${searchForm.orderDateStart}" );
		$( "#date2" ).datepicker( "setDate", "${searchForm.orderDateEnd}" );
		
		$('#mypager').bootstrapPaginator({
			currentPage:pageNum,
			totalPages:totalPage,
			numberOfPages:numPerPage,
			onPageClicked:function(event, originalEvent, type,page){
				$("input[name='pageNum']").val(page);
				$("#searchForm").submit();
			}
		});
		
		
		$('#searchBtn').click(function(){
			$("#searchForm").submit();
		})
		
		$('#clearBtn').click(function(){
			$("#date1,#date2,#search").val('');
			$('#sellerId,#status').val(-1);
		})
		
		
	})
	function edit(orderId){
			window.location.href = '<c:url value="/seller/addOrder?orderId='+orderId+'"/>';
		}
	</script>
</body>
</html>
